package com.example.harmonyos_ui.slice;

import com.example.harmonyos_ui.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;


public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        // 获取主活动页面的5个按钮
        Button button_to_login_prompt = (Button)findComponentById(ResourceTable.Id_button_to_login_prompt);
        button_to_login_prompt.setClickedListener(this::toLoginPrompt);
        Button button_to_char_scrooling_mode = (Button)findComponentById(ResourceTable.Id_button_to_char_scrooling_mode);
        button_to_char_scrooling_mode.setClickedListener(this::toCharScrollingMode);
        Button button_to_login_ui = (Button)findComponentById(ResourceTable.Id_button_to_login_ui);
        button_to_login_ui.setClickedListener(this::toLoginUi);
        Button button_to_login_ui_button = (Button)findComponentById(ResourceTable.Id_button_to_login_ui_button);
        button_to_login_ui_button.setClickedListener(this::toLoginUiButton);
        Button button_to_red_heart = (Button)findComponentById(ResourceTable.Id_button_to_red_heart);
        button_to_red_heart.setClickedListener(this::toRedHeart);
    }

    // 跳转到登陆提示信息页面
    public void toLoginPrompt(Component component) {
        // 创建意图
        Intent intent = new Intent();
        // 实现跳转
        this.present(new LoginPromptSlice(), new Intent());
    }

    // 跳转到文字跑马灯页面
    public void toCharScrollingMode(Component component) {
        // 创建意图
        Intent intent = new Intent();
        // 实现跳转
        this.present(new CharScrollingModeSlice(), new Intent());
    }

    // 跳转到登录UI页面
    public void toLoginUi(Component component) {
        // 创建意图
        Intent intent = new Intent();
        // 实现跳转
        this.present(new LoginUiSlice(), new Intent());
    }

    // 跳转到登录UI按钮页面
    public void toLoginUiButton(Component component) {
        // 创建意图
        Intent intent = new Intent();
        // 实现跳转
        this.present(new LoginUiButtonSlice(), new Intent());
    }

    // 跳转到红心页面
    public void toRedHeart(Component component) {
        // 创建意图
        Intent intent = new Intent();
        // 实现跳转
        this.present(new RedHeartSlice(), new Intent());
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
